home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 1 of 3 / CHAPTE22 / EX13.C < prev    next >
C/C++ Source or Header  |  1995-05-29  |  4KB  |  89 lines

  1. #include <genstub.c>
  2.  
  3. // Flags on bottom of table.
  4. #define LEGEND1 "ANSI character set flags. 1=Lower, 2=Upper, 4=Digit, 8=SPACE"
  5. #define LEGEND2 "                10=Punctuation, 20=Control, 40=Blank, 80=Hex"
  6.  
  7. LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  8. {
  9.    switch (uMsg)
  10.    {
  11.          case WM_COMMAND:
  12.                switch ( LOWORD( wParam ) )
  13.                {
  14.                      case IDM_TEST:
  15.                      {
  16.                            int   i, j;
  17.                            HFONT hOldFont;
  18.                            TCHAR szTemp[128];
  19.                            TCHAR szBuffer[128];
  20.                            TCHAR szLittleBuffer[17];
  21.                            WORD  wTypeArray[16];
  22.                            HDC   hDC = GetDC( hWnd );
  23.  
  24.                            hOldFont = SelectObject( hDC, GetStockObject(
  25.                                                     ANSI_FIXED_FONT ) );
  26.                            szTemp[0]=0;
  27.                            for ( j=0; j<16; j++ )
  28.                            {
  29.                               wsprintf( szBuffer, "%X ", j );
  30.                               lstrcat( szTemp, szBuffer );
  31.                            }
  32.                            lstrcpy( szBuffer, szTemp );
  33.                            lstrcat( szTemp, " ");
  34.  
  35.                            for ( j=0; j<16; j++ )
  36.                            {
  37.                               wsprintf( szBuffer, "%X ", j );
  38.                               lstrcat( szTemp, szBuffer );
  39.                            }
  40.                            TextOut(hDC, 22, 0, szTemp, lstrlen(szTemp) );
  41.  
  42.                            for ( i=0; i<16; i++ )
  43.                            {
  44.                               wsprintf( szTemp, "%2X ", i*16 );
  45.                               szLittleBuffer[0] = 0;
  46.                               for ( j=0; j<16; j++ )
  47.                               {
  48.                                  if (i==0 && j==0)
  49.                                     lstrcpy( szBuffer, " " );
  50.                                  else
  51.                                     wsprintf( szBuffer, "%c", j+i*16 );
  52.                                  lstrcat( szLittleBuffer, szBuffer );
  53.                                  lstrcat( szTemp, szBuffer );
  54.                                  lstrcat( szTemp, " " );
  55.                               }
  56.                               GetStringTypeA( LOCALE_USER_DEFAULT,CT_CTYPE1,
  57.                                               szLittleBuffer, 16, &wTypeArray );
  58.  
  59.                               for ( j=0; j<16; j++ )
  60.                               {
  61.                                  wsprintf( szBuffer, "%2X", (BYTE)wTypeArray[j] );
  62.                                  lstrcat( szTemp, szBuffer );
  63.                               }
  64.  
  65.                               TextOut( hDC, 0, (i + 1)*15, szTemp,
  66.                                        lstrlen( szTemp ) );
  67.                            }
  68.  
  69.                            TextOut( hDC, 60, 256, LEGEND1, lstrlen( LEGEND1 ) );
  70.                            TextOut( hDC, 60, 272, LEGEND2, lstrlen( LEGEND2 ) );
  71.                            TextOut( hDC, 60, 272, szBuffer, lstrlen(szBuffer) );
  72.  
  73.                            DeleteObject( SelectObject( hDC, hOldFont ) );
  74.                            ReleaseDC( hWnd, hDC );
  75.                      }
  76.                      break;
  77.                      case IDM_EXIT:
  78.                            DestroyWindow( hWnd );
  79.                      break;
  80.                }
  81.                break;
  82.          case WM_DESTROY:
  83.                PostQuitMessage( 0 );
  84.                break;
  85.          default:
  86.                return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
  87.    }
  88.    return( NULL );
  89. }